package com.zekai.dao.impl;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import com.common.dao.BaseDao;
import com.common.entity.DropOutOfSchool;
import com.common.entity.Employee;
import com.common.entity.ExamType;
import com.zekai.dao.IEmployeeDao;
import com.zekai.dao.IExamTypeDao;

import utils.Page;

public class ExamTypeDaoImpl extends BaseDao<ExamType> implements IExamTypeDao {

	@Override
	public String getNameById(int id) {
		String sql = "SELECT subName FROM examtype WHERE subNumber=?";
		String subName = null;
		PreparedStatement ps = null;
		ResultSet resultSet = null;
		Connection conn = null;
		try {
			conn = this.getConnection();
			ps = conn.prepareStatement(sql);
			ps.setObject(1, id);
			resultSet = ps.executeQuery();
			if (resultSet.next()) {
				subName = resultSet.getString("subName");
			}
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		closeAll(conn, ps, resultSet);
		return subName;
	}

	@Override
	public ExamType getEntity(ResultSet rs) {

		return null;
	}

	@Override
	public int getCount(String condition) {

		return 0;
	}

	@Override
	public List<ExamType> getOnePageInfo(String condition, int currentPage, int pageSize) {

		return null;
	}

	@Override
	public Page<ExamType> getPage(String condition, int currentPage, int pageSize) {

		return null;
	}

	@Override
	public int save(ExamType examType) {

		return 0;
	}

	@Override
	public int deleteById(int id) {

		return 0;
	}

	@Override
	public int update(ExamType examType) {

		return 0;
	}

	@Override
	public ExamType getExamTypeById(int id) {

		return null;
	}

	@Override
	public int getId(String code, String name) {

		return 0;
	}

	@Override
	public List<String> getSubName() {

		List<String> subNames = new ArrayList<String>();
		String sql = "SELECT subName FROM examtype";
		String subName = null;
		PreparedStatement ps = null;
		ResultSet resultSet = null;
		try {
			ps = this.getConnection().prepareStatement(sql);
			resultSet = ps.executeQuery();
			while (resultSet.next()) {
				subName = resultSet.getString("subName");
				subNames.add(subName);
			}

		} catch (SQLException e) {
			e.printStackTrace();
		}
		return subNames;
	}

	@Override
	public int getSubIdByName(String name) {
		int id=0;
		String sql="SELECT subNumber FROM examtype WHERE subName=?";
		PreparedStatement ps=null;
		ResultSet resultSet=null;
		try {
			ps=this.getConnection().prepareStatement(sql);
			ps.setObject(1, name);
			resultSet=ps.executeQuery();
			if(resultSet.next()) {
				id=resultSet.getInt("subNumber");
			}
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return id;
	}

}
